﻿namespace HuaWei.CBR.QTJL
{
    using DevExpress.Utils;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraEditors.Repository;
    using DevExpress.XtraGrid;
    using DevExpress.XtraGrid.Columns;
    using DevExpress.XtraGrid.Views.Base;
    using DevExpress.XtraGrid.Views.Grid;
    using HuaWei.CommClass;
    using HuaWei.CommComp;
    using HuaWei.Common;
    using HuaWei.Windows.Forms;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FrmCFLX : FrmBase
    {
        private BindingSource bindingSource;
        private SimpleButton btnSP;
        private DateEdit detSPRQ;
        private TextEdit edtSPR;
        private MemoEdit edtSPYJ;
        private GridColumn gridColumn1;
        private GridColumn gridColumn11;
        private GridColumn gridColumn12;
        private GridColumn gridColumn15;
        private GridColumn gridColumn16;
        private GridColumn gridColumn38;
        private GridColumn gridColumn9;
        private GridControl gridControl4;
        private GridView gridView4;
        private GroupControl groupControl6;
        private IContainer icontainer1 = null;
        private LabelControl labelControl3;
        private LabelControl labelControl4;
        private LabelControl labelControl5;
        private PanelControl panelControl10;
        private SimpleButton simpleButton11;
        private SimpleButton simpleButton12;
        private SimpleButton simpleButton2;
        private RepositoryItemCheckEdit vroAaJyIa;

        public FrmCFLX()
        {
            this.InitializeComponent();
            this.btnSP.Visible = !GParams._JGLX.Equals(JGLX.CBR);
        }

        private void btnSP_Click(object sender, EventArgs e)
        {
            FrmSPYJ mspyj = new FrmSPYJ();
            mspyj.SetFrmParam(this.bindingSource);
            mspyj.ShowDialog();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.icontainer1 != null))
            {
                this.icontainer1.Dispose();
            }
            base.Dispose(disposing);
        }

        private void FrmCFLX_Load(object sender, EventArgs e)
        {
            this.LoadData();
        }

        private void InitializeComponent()
        {
            this.icontainer1 = new Container();
            this.groupControl6 = new GroupControl();
            this.labelControl3 = new LabelControl();
            this.edtSPYJ = new MemoEdit();
            this.bindingSource = new BindingSource(this.icontainer1);
            this.edtSPR = new TextEdit();
            this.labelControl4 = new LabelControl();
            this.detSPRQ = new DateEdit();
            this.labelControl5 = new LabelControl();
            this.gridControl4 = new GridControl();
            this.gridView4 = new GridView();
            this.gridColumn9 = new GridColumn();
            this.gridColumn1 = new GridColumn();
            this.gridColumn11 = new GridColumn();
            this.gridColumn12 = new GridColumn();
            this.gridColumn15 = new GridColumn();
            this.gridColumn16 = new GridColumn();
            this.gridColumn38 = new GridColumn();
            this.vroAaJyIa = new RepositoryItemCheckEdit();
            this.panelControl10 = new PanelControl();
            this.simpleButton2 = new SimpleButton();
            this.btnSP = new SimpleButton();
            this.simpleButton11 = new SimpleButton();
            this.simpleButton12 = new SimpleButton();
            base.ds.BeginInit();
            base.dsQuery.BeginInit();
            base.dataSets.BeginInit();
            this.groupControl6.BeginInit();
            this.groupControl6.SuspendLayout();
            this.edtSPYJ.Properties.BeginInit();
            ((ISupportInitialize) this.bindingSource).BeginInit();
            this.edtSPR.Properties.BeginInit();
            this.detSPRQ.Properties.VistaTimeProperties.BeginInit();
            this.detSPRQ.Properties.BeginInit();
            this.gridControl4.BeginInit();
            this.gridView4.BeginInit();
            this.vroAaJyIa.BeginInit();
            this.panelControl10.BeginInit();
            this.panelControl10.SuspendLayout();
            base.SuspendLayout();
            this.groupControl6.Controls.Add(this.labelControl3);
            this.groupControl6.Controls.Add(this.edtSPYJ);
            this.groupControl6.Controls.Add(this.edtSPR);
            this.groupControl6.Controls.Add(this.labelControl4);
            this.groupControl6.Controls.Add(this.detSPRQ);
            this.groupControl6.Controls.Add(this.labelControl5);
            this.groupControl6.Dock = DockStyle.Bottom;
            this.groupControl6.Location = new Point(0, 0x14d);
            this.groupControl6.Name = "groupControl6";
            this.groupControl6.Size = new Size(0x2c9, 0xb7);
            this.groupControl6.TabIndex = 0x1c;
            this.groupControl6.Tag = "-3";
            this.groupControl6.Text = "审批意见";
            this.labelControl3.Location = new Point(12, 0x3b);
            this.labelControl3.Name = "labelControl3";
            this.labelControl3.Size = new Size(0x30, 14);
            this.labelControl3.TabIndex = 0x11;
            this.labelControl3.Text = "审批意见";
            this.edtSPYJ.DataBindings.Add(new Binding("EditValue", this.bindingSource, "SHYJ", true));
            this.edtSPYJ.Location = new Point(12, 0x4f);
            this.edtSPYJ.Name = "edtSPYJ";
            this.edtSPYJ.Properties.ReadOnly = true;
            this.edtSPYJ.Size = new Size(0x1d3, 0x60);
            this.edtSPYJ.TabIndex = 0x10;
            this.bindingSource.DataMember = "QTJL_CFKLX";
            this.bindingSource.DataSource = base.dataSets;
            this.edtSPR.DataBindings.Add(new Binding("EditValue", this.bindingSource, "SHR", true));
            this.edtSPR.Location = new Point(0xdf, 30);
            this.edtSPR.Name = "edtSPR";
            this.edtSPR.Properties.ReadOnly = true;
            this.edtSPR.Size = new Size(100, 0x15);
            this.edtSPR.TabIndex = 15;
            this.labelControl4.Location = new Point(0xb2, 0x21);
            this.labelControl4.Name = "labelControl4";
            this.labelControl4.Size = new Size(0x24, 14);
            this.labelControl4.TabIndex = 14;
            this.labelControl4.Text = "审批人";
            this.detSPRQ.DataBindings.Add(new Binding("EditValue", this.bindingSource, "SHRQ", true));
            this.detSPRQ.EditValue = null;
            this.detSPRQ.Location = new Point(0x45, 30);
            this.detSPRQ.Name = "detSPRQ";
            this.detSPRQ.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.detSPRQ.Properties.ReadOnly = true;
            this.detSPRQ.Properties.VistaTimeProperties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.detSPRQ.Size = new Size(100, 0x15);
            this.detSPRQ.TabIndex = 13;
            this.labelControl5.Location = new Point(12, 0x21);
            this.labelControl5.Name = "labelControl5";
            this.labelControl5.Size = new Size(0x30, 14);
            this.labelControl5.TabIndex = 12;
            this.labelControl5.Text = "审批日期";
            this.gridControl4.DataSource = this.bindingSource;
            this.gridControl4.Dock = DockStyle.Fill;
            this.gridControl4.EmbeddedNavigator.Buttons.Edit.Visible = false;
            this.gridControl4.Location = new Point(0, 0x1b);
            this.gridControl4.MainView = this.gridView4;
            this.gridControl4.Name = "gridControl4";
            this.gridControl4.RepositoryItems.AddRange(new RepositoryItem[] { this.vroAaJyIa });
            this.gridControl4.Size = new Size(0x2c9, 0x132);
            this.gridControl4.TabIndex = 0x19;
            this.gridControl4.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] { this.gridView4 });
            this.gridView4.Columns.AddRange(new GridColumn[] { this.gridColumn9, this.gridColumn1, this.gridColumn11, this.gridColumn12, this.gridColumn15, this.gridColumn16, this.gridColumn38 });
            this.gridView4.GridControl = this.gridControl4;
            this.gridView4.Name = "gridView4";
            this.gridView4.OptionsCustomization.AllowFilter = false;
            this.gridView4.OptionsCustomization.AllowSort = false;
            this.gridView4.OptionsView.ColumnAutoWidth = false;
            this.gridView4.OptionsView.ShowGroupPanel = false;
            this.gridColumn9.Caption = "应付日期";
            this.gridColumn9.FieldName = "YFRQ";
            this.gridColumn9.Name = "gridColumn9";
            this.gridColumn9.Visible = true;
            this.gridColumn9.VisibleIndex = 0;
            this.gridColumn1.Caption = "实付日期";
            this.gridColumn1.FieldName = "SFRQ";
            this.gridColumn1.Name = "gridColumn1";
            this.gridColumn1.Visible = true;
            this.gridColumn1.VisibleIndex = 1;
            this.gridColumn11.Caption = "迟付时间(天)";
            this.gridColumn11.FieldName = "CFSJ";
            this.gridColumn11.Name = "gridColumn11";
            this.gridColumn11.OptionsColumn.AllowEdit = false;
            this.gridColumn11.Tag = "";
            this.gridColumn11.Visible = true;
            this.gridColumn11.VisibleIndex = 2;
            this.gridColumn11.Width = 0x52;
            this.gridColumn12.Caption = "利率/日 ‰";
            this.gridColumn12.DisplayFormat.FormatString = "0";
            this.gridColumn12.DisplayFormat.FormatType = FormatType.Numeric;
            this.gridColumn12.FieldName = "LL";
            this.gridColumn12.Name = "gridColumn12";
            this.gridColumn12.Visible = true;
            this.gridColumn12.VisibleIndex = 3;
            this.gridColumn12.Width = 0x4a;
            this.gridColumn15.Caption = "迟付款额";
            this.gridColumn15.FieldName = "CFJE";
            this.gridColumn15.Name = "gridColumn15";
            this.gridColumn15.Visible = true;
            this.gridColumn15.VisibleIndex = 4;
            this.gridColumn15.Width = 0x51;
            this.gridColumn16.Caption = "应付利息";
            this.gridColumn16.FieldName = "YFLX";
            this.gridColumn16.Name = "gridColumn16";
            this.gridColumn16.OptionsColumn.AllowEdit = false;
            this.gridColumn16.Tag = "";
            this.gridColumn16.Visible = true;
            this.gridColumn16.VisibleIndex = 5;
            this.gridColumn16.Width = 0x54;
            this.gridColumn38.Caption = "同意上报";
            this.gridColumn38.ColumnEdit = this.vroAaJyIa;
            this.gridColumn38.FieldName = "TYSB";
            this.gridColumn38.Name = "gridColumn38";
            this.gridColumn38.ShowButtonMode = ShowButtonModeEnum.ShowOnlyInEditor;
            this.gridColumn38.Tag = "-1";
            this.gridColumn38.Visible = true;
            this.gridColumn38.VisibleIndex = 6;
            this.gridColumn38.Width = 60;
            this.vroAaJyIa.AutoHeight = false;
            this.vroAaJyIa.DisplayValueChecked = "1";
            this.vroAaJyIa.DisplayValueUnchecked = "0";
            this.vroAaJyIa.Name = "repositoryItemCheckEdit3";
            this.vroAaJyIa.NullStyle = StyleIndeterminate.Unchecked;
            this.vroAaJyIa.ValueChecked = 1;
            this.vroAaJyIa.ValueUnchecked = 0;
            this.panelControl10.Controls.Add(this.simpleButton2);
            this.panelControl10.Controls.Add(this.btnSP);
            this.panelControl10.Controls.Add(this.simpleButton11);
            this.panelControl10.Controls.Add(this.simpleButton12);
            this.panelControl10.Dock = DockStyle.Top;
            this.panelControl10.Location = new Point(0, 0);
            this.panelControl10.Name = "panelControl10";
            this.panelControl10.Size = new Size(0x2c9, 0x1b);
            this.panelControl10.TabIndex = 0x1b;
            this.simpleButton2.Dock = DockStyle.Left;
            this.simpleButton2.Location = new Point(0x98, 2);
            this.simpleButton2.Name = "simpleButton2";
            this.simpleButton2.Size = new Size(0x3a, 0x17);
            this.simpleButton2.TabIndex = 9;
            this.simpleButton2.Tag = "-2";
            this.simpleButton2.Text = "过程数据";
            this.simpleButton2.Click += new EventHandler(this.simpleButton2_Click);
            this.btnSP.Dock = DockStyle.Left;
            this.btnSP.Location = new Point(0x66, 2);
            this.btnSP.Name = "btnSP";
            this.btnSP.Size = new Size(50, 0x17);
            this.btnSP.TabIndex = 6;
            this.btnSP.Tag = "-1";
            this.btnSP.Text = "审批";
            this.btnSP.Click += new EventHandler(this.btnSP_Click);
            this.simpleButton11.Dock = DockStyle.Left;
            this.simpleButton11.Location = new Point(0x34, 2);
            this.simpleButton11.Name = "simpleButton11";
            this.simpleButton11.Size = new Size(50, 0x17);
            this.simpleButton11.TabIndex = 4;
            this.simpleButton11.Tag = "-1";
            this.simpleButton11.Text = "删除";
            this.simpleButton11.Click += new EventHandler(this.simpleButton11_Click);
            this.simpleButton12.Dock = DockStyle.Left;
            this.simpleButton12.Location = new Point(2, 2);
            this.simpleButton12.Name = "simpleButton12";
            this.simpleButton12.Size = new Size(50, 0x17);
            this.simpleButton12.TabIndex = 3;
            this.simpleButton12.Tag = "-1";
            this.simpleButton12.Text = "新增";
            this.simpleButton12.Click += new EventHandler(this.simpleButton12_Click);
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            base.ClientSize = new Size(0x2c9, 0x204);
            base.Controls.Add(this.gridControl4);
            base.Controls.Add(this.groupControl6);
            base.Controls.Add(this.panelControl10);
            base.Name = "FrmCFLX";
            this.Text = "迟付款利息";
            base.Load += new EventHandler(this.FrmCFLX_Load);
            base.ds.EndInit();
            base.dsQuery.EndInit();
            base.dataSets.EndInit();
            this.groupControl6.EndInit();
            this.groupControl6.ResumeLayout(false);
            this.groupControl6.PerformLayout();
            this.edtSPYJ.Properties.EndInit();
            ((ISupportInitialize) this.bindingSource).EndInit();
            this.edtSPR.Properties.EndInit();
            this.detSPRQ.Properties.VistaTimeProperties.EndInit();
            this.detSPRQ.Properties.EndInit();
            this.gridControl4.EndInit();
            this.gridView4.EndInit();
            this.vroAaJyIa.EndInit();
            this.panelControl10.EndInit();
            this.panelControl10.ResumeLayout(false);
            base.ResumeLayout(false);
        }

        public override void LoadedForm()
        {
            base.SetBindingSource(this.bindingSource, "QTJL_CFKLX", true);
            base.ds.Tables["QTJL_CFKLX"].TableNewRow += new DataTableNewRowEventHandler(Class28.smethod);
            base.ds.Tables["QTJL_CFKLX"].ColumnChanging += new DataColumnChangeEventHandler(this.method1);
            base.LoadedForm();
        }

        public override void LoadingData()
        {
            base.LoadingData();
            base.ds.Clear();
            string str = null;
            str = "select * from QTJL_CFKLX " + Class28.YfQclfhSo(GParams.QCInfo.QCID, "");
            Class39.smethod4(base.ida, base.ds, str, "QTJL_CFKLX", true);
        }

        private void lquywmUul(object sender, EventArgs e)
        {
            base.Save();
        }

        private void method1(object sender, DataColumnChangeEventArgs e)
        {
            if (e.Column.ColumnName.Equals("YFRQ") || e.Column.ColumnName.Equals("SFRQ"))
            {
                TimeSpan span;
                if (e.Column.ColumnName.Equals("YFRQ"))
                {
                    if (!(e.Row["SFRQ"] is DBNull))
                    {
                        span = (TimeSpan) (Convert.ToDateTime(e.Row["SFRQ"]) - Convert.ToDateTime(e.ProposedValue));
                        e.Row["CFSJ"] = span.Days;
                    }
                }
                else if (!(e.Row["YFRQ"] is DBNull))
                {
                    span = (TimeSpan) (Convert.ToDateTime(e.ProposedValue) - Convert.ToDateTime(e.Row["YFRQ"]));
                    e.Row["CFSJ"] = span.Days;
                }
            }
            if ((e.Column.ColumnName.Equals("CFSJ") || e.Column.ColumnName.Equals("LL")) || e.Column.ColumnName.Equals("CFJE"))
            {
                if (e.Column.ColumnName.Equals("CFSJ"))
                {
                    e.Row["YFLX"] = CHelp.ConvertDecimal(((double) ((CHelp.ConvertInt(e.ProposedValue, 0) * CHelp.ConvertInt(e.Row["CFJE"], 0)) * CHelp.ConvertInt(e.Row["LL"], 0))) / 1000.0, 0, 0);
                }
                else if (e.Column.ColumnName.Equals("CFJE"))
                {
                    e.Row["YFLX"] = CHelp.ConvertDecimal(((double) ((CHelp.ConvertInt(e.Row["CFSJ"], 0) * CHelp.ConvertInt(e.ProposedValue, 0)) * CHelp.ConvertInt(e.Row["LL"], 0))) / 1000.0, 0, 0);
                }
                else
                {
                    e.Row["YFLX"] = CHelp.ConvertDecimal(((double) ((CHelp.ConvertInt(e.Row["CFSJ"], 0) * CHelp.ConvertInt(e.Row["CFJE"], 0)) * CHelp.ConvertInt(e.ProposedValue, 0))) / 1000.0, 0, 0);
                }
            }
        }

        public override void Saving()
        {
            base.Saving();
            this.bindingSource.EndEdit();
        }

        private void simpleButton11_Click(object sender, EventArgs e)
        {
            if ((this.bindingSource.List.Count > 0) && (MsgBox.ShowQuestion("是否删除当前记录？") == System.Windows.Forms.DialogResult.OK))
            {
                this.bindingSource.RemoveCurrent();
                base.Save();
            }
        }

        private void simpleButton12_Click(object sender, EventArgs e)
        {
            DHelp.DataAddNew(this.bindingSource, "", "");
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            string objId = DHelp.GetObjId(this.bindingSource);
            base.OpenDataLog("QTJL_CFKLX", GParams._BDID, GParams.QCInfo.QCID, objId);
        }
    }
}

